<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {margin: 0;overflow: hidden;}
    #canvas {background-color: antiquewhite;}
  </style>
</head>
<body>
  <canvas id="canvas"></canvas>
  <script>
    /** @type {HTMLCanvasElement} */
    const canvas = document.querySelector('#canvas');
    canvas.width = window.innerWidth;
    canvas.height = window.innerHeight;
    const ctx = canvas.getContext('2d');

    ctx.strokeStyle = 'maroon';

    ctx.save();
    ctx.beginPath();
    ctx.moveTo(50,100);
    ctx.lineTo(700,100);
    ctx.setLineDash([60]);
    ctx.stroke();
    ctx.restore();

    ctx.save();
    ctx.beginPath();
    ctx.moveTo(50,200);
    ctx.lineTo(700,200);
    ctx.setLineDash([60]);
    ctx.lineDashOffset = -30;
    ctx.stroke();
    ctx.restore();
  </script>
</body>
</html>